package com.five.dao.impl.backstage;

import com.five.dao.backstage.IMenuDao;
import com.five.util.DBUtil;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 越川豪
 * @Date: 2020/12/1 20:06
 */

@Repository
public class IMenuDaoImpl implements IMenuDao {
    @Override
    public List<Map> getAllParent() {
        String sql = "select * from t_menu where mpid = 0";
        return DBUtil.queryMap(sql);
    }

    @Override
    public List<Map> getAllparMenuByRid(String rid) {
        String sql = "SELECT * FROM T_MENU WHERE mid IN ( SELECT mid FROM t_role_menu WHERE rid = ? ) and mpid=0";
        return DBUtil.queryMap(sql,rid);
    }

    @Override
    public List<Map> getMenusByPidAndRid(Object mid, String rid) {
        String sql="SELECT * FROM T_MENU WHERE mid IN ( SELECT mid FROM t_role_menu WHERE rid = ? ) and mpid=?";
        return DBUtil.queryMap(sql,rid,mid);
    }
}
